import unittest
from main.练习.lianxi12.Page.Page import Page
from main.练习.lianxi12.Page.Page2 import Page2
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from time import sleep
class Case(unittest.TestCase):
    def setUp(self) -> None:
        print('开始')
        self.driver=webdriver.Edge()
    def tearDown(self) -> None:
        print('结束')
    def test_01_baidu(self):
        op=Page(self.driver)
        op.open_url_loc()
        op.headerLogin()
        sleep(2)
        op.uname()
        op._pwd()
        sleep(10)
        op.save()
        sleep(2)
        op.bindSub()
        sleep(5)
        login_loc=self.driver.find_element(By.XPATH,'/html/body/div[2]/div/div[1]/div/p/span').text
        print(login_loc)
        self.assertEqual('jxw779222753',login_loc)
    def test_02_baidu(self):
        op=Page2(self.driver)
        op.jiuxianwang_loc2()
        sleep(2)
        op.wodejiuxian()
        sleep(2)
        op.switch_window_l()
        sleep(2)
        op.uGuideClose()
        sleep(2)
        op.execute_script_L()
        sleep(2)
        op.shouhuodiz()
        sleep(2)
        op.execute_script_L2()
        sleep(2)
        op.consignee()
        sleep(2)
        province=Select(self.driver.find_element(By.NAME,'province'))
        province.select_by_value('2')
        sleep(5)
        city=Select(self.driver.find_element(By.NAME,'city'))
        city.select_by_index(1)
        sleep(2)
        district=Select(self.driver.find_element(By.NAME,'district'))
        district.select_by_visible_text('昌平区')
        sleep(2)
if __name__ == '__main__':
    unittest.main()